package com.futu.attraction.controller;

import com.futu.attraction.domain.City;
import com.futu.attraction.service.CityService;
import com.futu.common.annotation.NoLoginRequired;
import com.futu.common.vo.ResultVo;
import com.futu.scenicspot.domain.HPlayProject;
import com.futu.scenicspot.domain.HScenicSpot;
import com.futu.scenicspot.service.HPlayProjectService;
import com.futu.scenicspot.service.HScenicSpotCategoryService;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/category")
public class CategoryController {

    @Resource
    private HScenicSpotCategoryService categoryService;

    @Resource
    private HPlayProjectService hPlayProjectService;
    @Resource
    private CityService cityService;

    @RequestMapping("/findByCategoryId")

    public ResultVo findByCategoryId(Long categoryId) {
        List<HScenicSpot> hScenicSpots= categoryService.findByCategoryId(categoryId);
        return ResultVo.success(hScenicSpots);
    }

    @RequestMapping("/findByCity")

    public ResultVo findByCity(@RequestParam String cityName) {
        List<HScenicSpot> hScenicSpots= categoryService.findByCity(cityName);
        return ResultVo.success(hScenicSpots);
    }

    @RequestMapping("findByAll")

    public ResultVo findByAll() {

        final List<City> list = cityService.list();
        System.err.println(list);
        return ResultVo.success(list);
    }
    @RequestMapping("findBySpot")

    public ResultVo findBySpot(Long spotId) {
        List<HPlayProject> hPlayProjects=hPlayProjectService.findBySpot(spotId);
        return ResultVo.success(hPlayProjects);
    }
}
